package com.cargohu.aishouyu.app;

import com.cargohu.aishouyu.common.CommonConstants;
import com.cargohu.aishouyu.framework.response.ApiResult;
import com.cargohu.aishouyu.system.service.SysConfigService;
import com.cargohu.aishouyu.system.vo.SysConfigVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * APP助手接口
 *
 * @author yww
 * @since 2023-11-30
 */
@Slf4j
@RestController
@RequestMapping(CommonConstants.API_APP_PATH+"/assistant")
@Tag(name = "APP助手接口(移动端)")
public class AppAssistantController {

    @Autowired
    private SysConfigService sysConfigService;

    /**
     * 用户调研链接
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/user-survey-url")
    @Operation(summary = "用户调研链接")
    public ApiResult<String> getUserSurveyUrl() throws Exception {
        SysConfigVo sysConfig = sysConfigService.getSysConfigByKey("app.userSurvey.url");
        return ApiResult.success(null == sysConfig ? null : sysConfig.getConfigValue());
    }

    /**
     * 故障提交链接
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/fault-submit-url")
    @Operation(summary = "故障提交链接")
    public ApiResult<String> getFaultSubmitUrl() throws Exception {
        SysConfigVo sysConfig = sysConfigService.getSysConfigByKey("app.faultSubmit.url");
        return ApiResult.success(null == sysConfig ? null : sysConfig.getConfigValue());
    }

    /**
     * 用户建议链接
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/user-suggest-url")
    @Operation(summary = "用户建议链接")
    public ApiResult<String> getUserSuggestUrl() throws Exception {
        SysConfigVo sysConfig = sysConfigService.getSysConfigByKey("app.userSuggest.url");
        return ApiResult.success(null == sysConfig ? null : sysConfig.getConfigValue());
    }

}
